/**
 * Name        : FileDialog.h
 * Version     : 1.1.0
 * Vendor      : badadev.com
 * Description : Component for browsing directories and selecting files
 * Lincense    : This program is free software. It comes without any warranty, to
 *               the extent permitted by applicable law. You can redistribute it
 *               and/or modify it under the terms of the Do What The Fuck You Want
 *               To Public License, Version 2, as published by Sam Hocevar. See
 *               http://sam.zoy.org/wtfpl/COPYING for more details.
 */

#ifndef FILEDIALOG_H_
#define FILEDIALOG_H_

#include <FBase.h>
#include <FGraphics.h>
#include <FUi.h>
#include <FIo.h>

#include "InheritanceContainer.h"
#include "FileDialogNew.h"


namespace badadev {

class FileDialog :
	public Osp::Ui::Controls::Form,
	public InheritanceContainer,
	private Osp::Ui::IActionEventListener,
 	private Osp::Ui::IOrientationEventListener,
	private Osp::Ui::IItemEventListener
{
public:
	static const int ON_SELECTED = 4001;
	static const int ON_CANCELED = 4002;
	static const int ON_NEW = 4003;

	FileDialog();
	virtual ~FileDialog();

	bool	IsLoad;
	result Initialize(const Osp::Base::String & title, InheritanceContainer &parent, const Osp::Base::String &ext );
	result ChDir(const Osp::Base::String & base_dir);
	void   GoTop( void );
	Osp::Base::String getSelectedFilePath() { return selectedFile_;}

private:
	Osp::Ui::Controls::List* dircontentList_;
	Osp::Io::Directory* baseDir_;
	Osp::Base::String basePath_;
	Osp::Base::String supportExt_;
	Osp::Base::String selectedFile_;

	FileDialogNew * newDialog_;

	void SelectConfirm(Osp::Base::String filepath);
	void OnActionPerformed(const Osp::Ui::Control& source, int actionId);
	void OnOrientationChanged( const Osp::Ui::Control &source, Osp::Ui::OrientationStatus orientationStatus );
	void OnItemStateChanged(const Osp::Ui::Control& source, int index, int itemId,
										Osp::Ui::ItemStatus status);
	virtual void receiveContainerActionFromChild(const int actionId,
				                                     InheritanceContainer &child);
};

}

#endif /* FILEDIALOG_H_ */
